package com.sky.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.ArticlePageQueryDTO;
import com.sky.mapper.ArticleMapper;
import com.sky.result.PageResult;
import com.sky.service.AritcleService;
import com.sky.vo.ArticleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.List;

@Slf4j
@Service
public class ArticleServiceImpl implements AritcleService {

    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public List<ArticleVO> selectArticle() {
        List<ArticleVO> articleVOS = articleMapper.selectArticleSort();
        return articleVOS;
    }

    @Override
    public PageResult pageQuery(ArticlePageQueryDTO articlePageQueryDTO) {
        PageHelper.startPage(articlePageQueryDTO.getPage(),articlePageQueryDTO.getPageSize());
        Page<ArticleVO> page = articleMapper.pageQuery(articlePageQueryDTO);
        return new PageResult(page.getTotal(),page.getResult());
    }
}
